package com.jmp.api.dto;

import lombok.Builder;
import lombok.Data;
import com.jmp.base.enums.TemplateConfigTypeEnum;

import java.io.InputStream;
import java.util.List;
import java.util.Objects;

/**
 * @author cjr
 */
@Data
@Builder
public class TemplateParamDto {
    // 模板配置

    // 模板参数
    private Integer cardId;
    private Integer goodsId;
    private Integer articleId;
    private Integer roomId;
    private Integer groupId;

    // 自定义图片
    private InputStream diyImg;
    private String diyUrl;

    /**
     * 替换背景图
     */
    private String backgroundUrl;
    /**
     * 过滤配置组件
     */
    private List<TemplateConfigTypeEnum> configExclude;
    /**
     * 文章分享URL
     */
    private String articleH5Url;
    private String groupH5Url;
    private String groupPrice;

    public String getRateId() {
        StringBuilder id = new StringBuilder().append(cardId);
        if (Objects.nonNull(goodsId)) {
            id.append(";").append(goodsId);
        }
        if (Objects.nonNull(articleId)) {
            id.append(";;").append(articleId);
        }
        if (Objects.nonNull(roomId)) {
            id.append(";;;").append(roomId);
        }
        if (Objects.nonNull(groupId)) {
            id.append(";;;:").append(groupId).append("-").append(groupH5Url);
        }
        return id.toString();
    }
}
